// LinePoint.h: interface for the CLinePoint class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_LINEPOINT_H__A9E0F372_1302_45D5_B033_66444E32C003__INCLUDED_)
#define AFX_LINEPOINT_H__A9E0F372_1302_45D5_B033_66444E32C003__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


struct SPoint;

/// line point set
struct SLinePoint
{
public:
	/// head ptr for data set
	const SPoint	*m_lpPoint;
	/// count of m_lpPoint
	int		m_nPoint;

public:
	BOOL getMaxRect(RECT *lpRect) const;
	BOOL getGivenAngleMaxPoint(SPoint *lpPoint, int dx, int dy) const;
	BOOL checkConnected(const SLinePoint *lpLine) const;
	float getSumLength(void) const;

public:
	static float inRect(const RECT *lpRect, const SPoint *lpPt1, const SPoint *lpPt2);
};

/// line point set, with length/rectangle cache
struct SLinePointEx : public SLinePoint
{
public:
	SLinePointEx();
	~SLinePointEx();

public:
	/// count is m_nPoint-1
	float	*m_pfLength;
	/// maximum rectangle
	RECT	m_rect;
	/// total length
	float	m_fLength;

public:
	BOOL createFrom(const SLinePoint *lpLine);
	BOOL getCenter(float *pfX, float *pfY, float *pfWeight) const;
	float getInRectRatio(const RECT *lpRect) const;

public:
	float getLeftXRatio(float fX) const;
	float getTopYRatio(float fY) const;
	float getCrossXRatio(float fX) const;
	float getCrossYRatio(float fY) const;
	float getRatioInRect(const RECT *lpRect) const;

protected:
	SLinePointEx(const SLinePointEx&);
	SLinePointEx& operator=(const SLinePointEx&);
};

#endif // !defined(AFX_LINEPOINT_H__A9E0F372_1302_45D5_B033_66444E32C003__INCLUDED_)
